<template>
	<!-- 页面标注调试用的页面 -->
	<view class="inspectContent">
		<web-view class="webMap" :src="mapUrl"  @message="callback"  ></web-view>
	</view>
</template>

<script> 
		
	export default { 
		components: { 
			
		},
		data() {
			return {  
				mapUrl : '../hybrid/html/tagging.html',
				localInfo: {}
			}
		},  
		async onLoad(params) {  
			 if(params.lng_lat == null || params.lng_lat == 'undefined' || params.lng_lat == ''){
				 params.lng_lat = "0,0";
			 } 
			 let lngLatArr = params.lng_lat.split(",");
			 this.mapUrl = this.mapUrl + "?lng="+ lngLatArr[0] + "&lat="+lngLatArr[1] 
		},
		methods: { 
			 callback(event){ 
				if(event.detail.data[0].type == 'back'){
				   uni.navigateBack(); 
				}
				if(event.detail.data[0].type == 'result'){
				   this.savePoint(event.detail.data[0].lng,event.detail.data[0].lat);
				}
			 },
			 async savePoint(longitude, latitude) {
				 console.log(latitude)
			 	const that = this;
			 	uni.showLoading({
			 		title: '存储新的坐标信息',
					mask: true
			 	});
			 	const res2 = await uni.$api.editCompanyPoint({
			 		companyId: that.companyId,
			 		lng: longitude,
			 		lat: latitude,
			 	});
			 	if (res2.data.code == '0') {
			 		uni.showToast({
			 			icon: 'success',
			 			title: '标注成功'
			 		})
			 		//修改父页中的
			 		const eventChannel = that.getOpenerEventChannel();
			 		eventChannel.emit('updateLngLat', {
			 			lng_lat: longitude + "," + latitude
			 		});
			 		uni.navigateBack()
			 	} else {
			 		uni.showToast({
			 			icon: 'error',
			 			title: '标注失败,请尝试重新保存'
			 		})
			 	}
			 	uni.hideLoading()
			 }
		}, 
	}
</script>

<style lang="scss">
	.webMap{
		width: 100%;
		height: 100vh;
		position: absolute;
		top: 0px;
		z-index: 2;
	}
	 .point {
	 	position: absolute;
	 	z-index: 10;
	 	bottom: 160px;
	 	left: 20px;
	 	background-color: #FFFFFF;
	 	width: 50px;
	 	height: 50px;
	 	display: flex;
	 	align-items: center;
	 	justify-content: center;
	 }
	 
	 .bottom-content{
	 	position: absolute;
	 	bottom: 0px;
	 	height: 130px;
	 	width: 100%;
	 	padding-top: 20px;
	 				background-color: #fff;
	 				z-index: 20;
	 }
	 .point-item{
	 	padding: 5px 10px;
	 	display: flex;
	 	flex-direction: row;
	 	justify-content: flex-start;
	 	align-items: center;
	 }
	 .point-icon{
	 	width: 25px;
	 	height: 25px;
	 }
	 .point-text{
	 	color: black;
	 	font-size: 14px;
	 	margin-left: 5px;
	 }
	 .point-input{
	 	width: 500rpx;
	 	height: 40px;
	 	margin-left: 10px;
	 	margin-right: 10px;
	 	padding: 0px 5px ;
	 	border: 1px solid #e8e8e7;
	 } 
</style>
